$(function(){ 
		var bot_id = $('#bot_id').val();
		//Ajax调用处理
		var chat_get_friend = $.ajax({
			type: "POST",
			url: "index.php?m=bot&c=bot_chat&a=chat_get_friend",
			data: "bot_id="+bot_id,
			async: false
		}).responseText;
		document.getElementById('chat_get_friend').innerHTML = chat_get_friend;		
		var chat_get_group = $.ajax({
			type: "POST",
			url: "index.php?m=bot&c=bot_chat&a=chat_get_group",
			data: "bot_id="+bot_id,
			async: false
		}).responseText;
		document.getElementById('chat_get_group').innerHTML = chat_get_group;	
		var chat_get_category = $.ajax({
			type: "POST",
			url: "index.php?m=bot&c=bot_chat&a=chat_get_category",
			data: "bot_id="+bot_id,
			async: false
		}).responseText;
		document.getElementById('chat_get_category').innerHTML = chat_get_category;
    });
function addmsgobj(addname,addid)
{
	var bot_id = $('#bot_id').val();
	var sendmodelnow = $('#sendmodelnow').val();
	if (sendmodelnow == 'all') {
		var oldname = $('#sendmsgobjname').val();
		var oldid = $('#sendmsgobjid').val();
		var newname = addname+','+oldname;
		var newid = addid+','+oldid;
	} else if (sendmodelnow == 'one') {
		var newname = addname+',';
		var newid = addid+',';
	}
	document.getElementById('sendmsgobjname').value = newname;
	document.getElementById('sendmsgobjid').value = newid;
}
function sendmsg() 
{
	var bot_id = $('#bot_id').val();
	var sendmsgobj = $('#sendmsgobjid').val();
	var sendmsgbody = $('#sendmsgbody').val();
	if($("#sendmsgobjid").val() == ""){  
		toastr.warning("发送对象不能为空！");  
		$("#sendmsgobjid").focus();  
		return false;  
    } 
	if($("#sendmsgbody").val() == ""){  
		toastr.warning("发送内容不能为空！");  
		$("#sendmsgbody").focus();  
		return false;  
    } 
	$.ajax({
		type: "post",
		url: "index.php?m=bot&c=bot_chat&a=sendmsg",
		data: "bot_id="+bot_id+"&sendmsgobj="+sendmsgobj+"&sendmsgbody="+sendmsgbody,
		success: function (result) {
			document.getElementById('sendmsg_do').value = '';
			document.getElementById('sendmsg_do').value = result;
			}
	});
	$("#sendmsgbody").val("");
}
function showmsg() 
{
	var bot_id = $('#bot_id').val();
	$.ajax({
		type: "post",
		url: "index.php?m=bot&c=bot_chat&a=showmsg",
		data: "bot_id="+bot_id,
		success: function (result) {
			$("#showmsg").append(result); 
			var div = document.getElementById("showmsg");
			div.scrollTop = div.scrollHeight;
			}
	});
}
function sendmodelset()
{
	var bot_id = $('#bot_id').val();
	var sendmodeltext = $('#sendmodeltext').val();
	var sendmodelnow = $('#sendmodelnow').val();
	if (sendmodelnow == 'one') {
		var newsendmodeltext = ' 模式切换：多发模式 ';
		var newsendmodelnow = 'all';
	} else if (sendmodelnow == 'all') {
		var newsendmodeltext = ' 模式切换：单发模式 ';
		var newsendmodelnow = 'one';
	}
	document.getElementById('sendmodeltext').innerHTML = newsendmodeltext;
	document.getElementById('sendmodelnow').value = newsendmodelnow;
}
function clearsendobj()
{
	var bot_id = $('#bot_id').val();
	document.getElementById('sendmsgobjname').value = '';
	document.getElementById('sendmsgobjid').value = '';
}